﻿// -----------------------------------------------------------------------
// <copyright file="OrderdFilter.cs" company="FCIS">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace LastVersionOfIpPackage.Operations
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using System.Text; 
    using Enum_needed;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class OrderdFilter
    {
        /// <summary>
        /// static object of this class to use this without create object
        /// </summary>
        private static OrderdFilter instance = new OrderdFilter();

        /// <summary>
        /// Gets or sets the instance.
        /// </summary>
        /// <value>
        /// The instance.
        /// </value>
        public static OrderdFilter Instance
        {
            get { return OrderdFilter.instance; }
            set { OrderdFilter.instance = value; }
        }

        /// <summary>
        /// Applies the max filter.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="maskSize">Size of the mask.</param>
        /// <param name="myTypeOfFilter">My type of filter order or geomtric.</param>
        /// <returns>
        /// the modified bitmap image
        /// </returns>
       public Bitmap ApplyFiltersOrderStaticsAndMeanGeom(Bitmap image, int maskSize, OrderStatisticType myTypeOfFilter)
       {
           Color[,] bufferOfImage = BufferOfImage.Buffer.GetBuffer(image);
           Color[,] buffer = LinearConvolution.LinerConvalution.AddBorder(bufferOfImage, maskSize);
           if (myTypeOfFilter != OrderStatisticType.Mean)
           {
               bufferOfImage = LinearConvolution.LinerConvalution.LinearConvolutionOrderdFilterFn(bufferOfImage, buffer, maskSize, myTypeOfFilter);
           }
           else
           {
               bufferOfImage = LinearConvolution.LinerConvalution.LinearConvolutionGeometricFn(image, buffer, maskSize);
           } 
           
           return BufferOfImage.Buffer.GetImage(bufferOfImage);
       }
       }
}
